package com.woniuxy.java102vuecli.configuration;

import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author author
 * @Create 2023-09-28 11:32
 */
@Configuration
public class RabbitConfiguration {

    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Queue queueemail(){
        return new Queue("queueemail");
    }

    //topisc模式使用topic类型的交换机
    @Bean
    public TopicExchange exchangetopic(){
        return new TopicExchange("exchangetopic");
    }

    @Bean
    public Binding bindingqueueemailtoexchangetopic(Queue queueemail, TopicExchange exchangetopic){
        return BindingBuilder.bind(queueemail).to(exchangetopic).with("#.email.#");
    }

}
